<script setup lang="ts">
import ShowCase from "./components/02_IfShowCase.vue"
import IfShowCase from "./components/03_Vue3事件传参.vue";
import BindCase from "./components/04_Vue3的属性绑定.vue"
import ForCase from "./components/05_Vue3中循环列表.vue"
import ModelCase from "./components/06_Vue中的双向绑定.vue"
import ComputedCase from "./components/07_Vue3中的计算属性.vue"
import WatchCase from "./components/08_Vue3中的侦听器.vue"
import LifeCase from './components/09_Vue3生命周期钩子函数.vue'
import ListV2Case from './components/10_Vue2生命周期函数.vue'
import RefCase from './components/11_通过ref获取dom元素.vue'
// import { ref } from "vue"
// const showCom = ref(true)
import NBCase from './components/12_综合案例.vue'
import HmHeader from "./components/HmHeadr.vue"
import HmBody from "./components/HmContainer.vue"
import HmFooter from "./components/HmFooter.vue"
import HmButton from "./components/HmButton.vue";
import { createApp } from "vue";
import Parent from './components/13_父子通信中的父组件.vue'
import GrandFather from "./components/15_跨组件传值的爷爷组件.vue"
import SlotCase from './components/18_具名插槽.vue'
import HmTable from './components/19_Vue3中封装table组件.vue'
import TestTable from './components/20_作用域插槽的简单版本.vue'
import { ref } from "vue"

type PersonColumnArr = Array<{ label: string, field: string }>
type PersonArr = Array<{ id: number, username: string, age: number }>
const columns: PersonColumnArr = [
  { label: '序号', field: "id" },
  { label: '姓名', field: "username" },

  { label: '年纪', field: "age" },
  { label: '操作', field: "" },
]

const data = ref<PersonArr>([
  {
    id: 1,
    username: '张小华',
    age: 18
  },
  {
    id: 2,
    username: '高大明',
    age: 18
  }, {
    id: 3,
    username: '刘德住',
    age: 20
  }

])

const delRow = (row: { id: number, username: string, age: number }) => {
  data.value = data.value.filter(item => item.id !== row.id)
}
</script>

<template>
  <!-- <ShowCase></ShowCase> -->
  <!-- <show-case></show-case> -->
  <!-- <ShowCase></ShowCase> -->
  <!-- <IfShowCase></IfShowCase> -->
  <!-- <BindCase></BindCase> -->
  <!-- <ForCase></ForCase> -->
  <!-- <ModelCase></ModelCase> -->
  <!-- <ComputedCase></ComputedCase> -->
  <!-- <WatchCase></WatchCase> -->
  <!-- <LifeCase v-if="showCom"></LifeCase> -->
  <!-- <ListV2Case></ListV2Case> -->
  <!-- <button @click="showCom = !showCom">创建/销毁</button> -->
  <!-- <RefCase></RefCase> -->
  <!-- <NBCase></NBCase> -->
  <!-- <div class="container">
    <HmHeader></HmHeader>
    <HmBody></HmBody>
    <HmFooter></HmFooter>
  </div> -->
  <!-- <button>测试</button>
  <Parent></Parent> -->
  <!-- <GrandFather></GrandFather> -->
  <!-- <SlotCase>
    <template #header>
      <h1>头部内容</h1>
    </template>
<template #body>
      <h1>主体内容</h1>
    </template>
<template #footer>
      <h1>底部内容</h1>
    </template>
<template #default>
      匿名插槽的传入
    </template>
</SlotCase> -->

  <!-- <HomTable :columns="columns" :data="data"> -->
  <!-- <template #row="obj">

      <button>编辑</button>
      <button @click="delRow(obj.row)">删除</button>
    </template> -->

  <!-- <TestTable>
      <template #row="{ p }">
        <h2>姓名：{{ p.name }}, 年龄： {{ p.age }}</h2>
      </template>
    </TestTable> -->
  <!-- </HomTable> -->


  <div class="container">
    <!-- 一级路由容器 -->
    <div class="nav">
      <router-link to="/home">去主页</router-link>
      <router-link to="/login">去登录</router-link>

    </div>


    <router-view>
    </router-view>
  </div>


</template>

<style scoped>
.container {
  width: 50%;
  height: 50vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background-color: pink;
}

.nav a {
  margin-left: 10px;
  text-decoration: none;
}

.router-link-active {
  font-size: 30px;
}
</style>
